import request from "@/utils/request";
import Qs from "qs";

// 列表数据
export function listCoupon(query) {
  return request({
    method: "get",
    params: {
      _gp: "admin.XHCoupon",
      _mt: "page",
      ...query
    }
  });
}

// 添加数据
export function createCoupon(data) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "create",
      ...data
    })
  });
}

// 删除单条数据
export function deleteCoupon(id) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "delete",
      id
    })
  });
}

// 批量删除
export function batchDeleteCoupon(ids) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "batchDelete",
      ids: JSON.stringify(ids)
    })
  });
}

// 修改
export function updateCoupon(data) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "update",
      ...data
    })
  });
}

// 详情
export function detailCoupon(id) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "detail",
      id
    })
  });
}
// 发放
export function grantCoupon(data) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "grant",
      ...data
    })
  });
}

// 撤销

export function revocationCoupon(uuid) {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.XHCoupon",
      _mt: "cancelAfterVerification",
      uuid: uuid
    })
  });
}

// 持有人数据

export function enterpriseSelectCoupon() {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.enterprise",
      _mt: "enterpriseSelect"
    })
  });
}

// 发放人数据

export function selectAdminCoupon() {
  return request({
    method: "post",
    data: Qs.stringify({
      _gp: "admin",
      _mt: "selectAdmin"
    })
  });
}
